package com.xrf;

import java.io.*;
import java.util.List;
import java.util.Scanner;

public class DataManager {
    private static Scanner scanner = new Scanner(System.in);

    // 通用的数据操作方法
    public static <T> void addData(List<T> list, DataCreator<T> creator) {
        System.out.println("--------添加数据-------");
        T data = creator.createData();
        list.add(data);
        System.out.println("添加成功！");
    }

    public static <T> void removeData(List<T> list) {
        System.out.println("--------删除数据-------");
        System.out.println("请输入索引：");
        int index = scanner.nextInt();
        if (index >= 0 && index < list.size()) {
            list.remove(index);
           